#ifndef IOCTLSERIALIZER_H
#define IOCTLSERIALIZER_H

#include "MyBuffer.h"
#include "URBSerializer.h"
#include <wdm.h>
#include <usbioctl.h>

#define PACK_IOCTL_INTERNAL_USB_CYCLE_PORT                  0
#define PACK_IOCTL_INTERNAL_USB_GET_BUS_INFO                1
#define PACK_IOCTL_INTERNAL_USB_GET_CONTROLLER_NAME         2
#define PACK_IOCTL_INTERNAL_USB_GET_DEVICE_CONFIG_INFO      3
#define PACK_IOCTL_INTERNAL_USB_GET_HUB_NAME                4
#define PACK_IOCTL_INTERNAL_USB_GET_PORT_STATUS             5
#define PACK_IOCTL_INTERNAL_USB_GET_TOPOLOGY_ADDRESS        6
#define PACK_IOCTL_INTERNAL_USB_RESET_PORT                  7
#define PACK_IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION    8
#define PACK_IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION  9
#define PACK_IOCTL_USB_GET_HUB_CAPABILITIES                 10
#define PACK_IOCTL_USB_GET_HUB_CAPABILITIES_EX              11
#define PACK_IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME   12
#define PACK_IOCTL_USB_GET_NODE_CONNECTION_INFORMATION      13
#define PACK_IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX   14
#define PACK_IOCTL_USB_GET_NODE_CONNECTION_NAME             15
#define PACK_IOCTL_USB_GET_NODE_INFORMATION                 16
#define PACK_IOCTL_USB_GET_ROOT_HUB_NAME                    17
#define PACK_IOCTL_USB_HUB_CYCLE_PORT                       18
#define PACK_IOCTL_USB_USER_REQUEST                         19


class IOCTLSerializer
{
public:
	IOCTLSerializer(){}
	~IOCTLSerializer(){}
	
	ULONG SerializeIOCTL(PIRP pIrp, PVOID pBuffer, ULONG bufferSize, BOOLEAN isCompleted);

private:
	MyBuffer buffer;
	URBSerializer urbSerializer;

	ULONG SerializeEmptyPacket(UCHAR type, BOOLEAN isCompleted, PIRP pIrp);

#if (_WIN32_WINNT >= 0x0600)
	ULONG SerializeUsbIdString(PUSB_ID_STRING pString);
#endif

	ULONG SerializeGUID(GUID *pGUID);
};

#endif // IOCTLSERIALIZER_H